# Contributor: John Boehr <jbboehr@gmail.com>
# Maintainer: Rafael del Valle <rvalle@privaz.io>
pkgname=handlebars
_pkgname=handlebars.c
pkgver=1.0.0
pkgrel=1
_mustachespec_ver="83b0721610a4e11832e83df19c73ace3289972b9"
_handlebarsspec_ver="3eb919f19988f37a539779c08342d2ce50aa75d0"
pkgdesc="C implementation of handlebars.js"
url="https://github.com/jbboehr/handlebars.c"
license="LGPL-2.1-or-later"
arch="all !armv7"
makedepends="
	autoconf
	automake
	bison
	check-dev
	flex
	json-c-dev
	libtool
	pcre-dev
	talloc-dev
	yaml-dev
	"
subpackages="$pkgname-dev $pkgname-utils"
source="$_pkgname-$pkgver.tar.gz::https://github.com/jbboehr/handlebars.c/archive/v$pkgver.tar.gz
	mustache-spec-$_mustachespec_ver.tar.gz::https://github.com/mustache/spec/archive/$_mustachespec_ver.tar.gz
	handlebars-spec-$_handlebarsspec_ver.tar.gz::https://github.com/jbboehr/handlebars-spec/archive/$_handlebarsspec_ver.tar.gz
	"
builddir="$srcdir/$_pkgname-$pkgver"
options="!check" # bunch of off-by-one talloc failures

prepare() {
	mkdir -p spec
	ln -sf "$srcdir"/spec-$_mustachespec_ver spec/mustache
	ln -sf "$srcdir"/handlebars-spec-$_handlebarsspec_ver spec/handlebars

	default_prepare

	./bootstrap
}

build() {
	./configure \
		--prefix=/usr \
		--disable-refcounting \
		--disable-static
	make
}

check() {
	make test
}

package() {
	make DESTDIR="$pkgdir" install
}

utils() {
	pkgdesc="Handlebars command line utilities"

	amove usr/bin
}

sha512sums="
37f39db59253a9b8283441cfdec1b3bf5b2a7590c9d55b28679d7115e68ea1dae25b8008e3f443f3a5aa811e3c179ea76f6e70de28849099093f2867a133013d  handlebars.c-1.0.0.tar.gz
edc5cfeba455b932ea2732a19a7016ad84b9fb8bb8d7b0ee71c79f155c298620cce06e548d3c7adc297a69b7a2c85be2519ea4073d05c3519930d3bae0b022ba  mustache-spec-83b0721610a4e11832e83df19c73ace3289972b9.tar.gz
b8adb3ce8b6be1cc1e130fa3728d4f20b5a77e9773ccae9d91e2c161dad5356a23e2b531b56fe1da22846e93d2a94ebc32c70c144c9a2680914104bb4d8163fb  handlebars-spec-3eb919f19988f37a539779c08342d2ce50aa75d0.tar.gz
"
